#' @TODO 生成pdf、-72.tif、-300.tif三张图
#' @title 给定ggplot绘图对象p，生成pdf、-72.tif、-300.tif三张图
#' @param od 图片输出路径
#' @param name 图片名称
#' @param w 图片宽度，默认6
#' @param h 图片高度，默认6
#' @param p 图片存储对象
#' @export 
#' @return NULL
#' @examples plotout(p = p, num = 1, od = 'out_home')
#' @author *CY*
#'
plotout <- function(p = NULL, od = NULL, name = NULL, w = 6, h = 6, num = NULL, savetiff = F,
    plot_tif = savetiff) {

    if (!is.null(num)) {
        name <- num
        # warning(stringr::str_glue('In function {crayon::blue('plotout')}
        # @param {crayon::bold('num')} is replaced by @param
        # {crayon::bold('name')}.'))
    }

    if (!dir.exists(od)) {
        dir.create(od, recursive = TRUE)
    }

    pdf(file = paste0(od, "/Figure_", name, ".pdf"), width = w, height = h)
    print(p)
    dev.off()

    if (isTRUE(savetiff)) {
        tiff(file = paste0(od, "/Figure_", name, "-72.tif"), width = w, height = h,
            units = "in", res = 72)
        print(p)
        dev.off()
        tiff(file = paste0(od, "/Figure_", name, "-300.tif"), width = w, height = h,
            units = "in", res = 300)
        print(p)
        dev.off()
        png(file = paste0(od, "/Figure_", name, "-300.png"), width = w, height = h,
            units = "in", res = 300)
        print(p)
        dev.off()
    }
}



